package perso.perso.view.admin.user;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.client.ClientProtocolException;

import perso.perso.MyAction;
import perso.perso.view.admin.school.BeanSchool;
import perso.perso.wsclient.HttpMiddlewareSchoolWSCall;
import perso.perso.wsclient.HttpMiddlewareUserWSCall;

public class DisplayUserAdminAction extends MyAction {

	
	private static final long serialVersionUID = 1L;

	private List<Integer> days;
	private List<Integer> months;
	private List<Integer> years;
	private List<BeanSchool> schools;
	
	private String idTeacher;
	
	public DisplayUserAdminAction(){
		days = new ArrayList<Integer>();
		for (int i = 1; i <= 31; i++) {
			days.add(i);
		}

		months = new ArrayList<Integer>();
		for (int i = 1; i <=12; i++) {
			months.add(i);
		}

		years = new ArrayList<Integer>();
		for (int i = 2011; i >= 1950; i--) {
			years.add(i);
		}
		
		HttpMiddlewareSchoolWSCall h = new HttpMiddlewareSchoolWSCall();
		try {
			schools = h.getAllSchools();
		} catch (ClientProtocolException e) {
			schools = new ArrayList<BeanSchool>();
		} catch (IOException e) {
			schools = new ArrayList<BeanSchool>();
		}
	}
	
	public List<Integer> getDays() {
		return days;
	}



	public void setDays(List<Integer> days) {
		this.days = days;
	}



	public List<Integer> getMonths() {
		return months;
	}



	public void setMonths(List<Integer> months) {
		this.months = months;
	}



	public List<Integer> getYears() {
		return years;
	}



	public void setYears(List<Integer> years) {
		this.years = years;
	}




	public List<BeanSchool> getSchools() {
		return schools;
	}

	public void setSchools(List<BeanSchool> schools) {
		this.schools = schools;
	}

	
	
	public String getIdTeacher() {
		return idTeacher;
	}

	public void setIdTeacher(String idTeacher) {
		this.idTeacher = idTeacher;
	}

	@Override
	public String execute() throws Exception {
		
	
		HttpMiddlewareUserWSCall h = new HttpMiddlewareUserWSCall();
		
		
		this.httpServletRequest.setAttribute("listUsers", h.getAllUsers());
		
		return SUCCESS;
	}

	
	
	
	
}
